<?php
/**
 * @page map_pointers Map Pointers
 * 
 * Crowd Vox also allows you to have custom pointers on your map, if you have @ref geomap enabled. Here's 
 * how it works:
 * 
 * 1. Upload all your icons in directory: 
 * 
 * \\app\\webroot\\geo_images
 * 
 * 2. Goto Backend > Settings > Map Icons
 * 
 * 3. Select an icon, and check categories to assign that icon, and press submit.
 *
 */
	class MapIcon extends AppModel
	{
		var $name = "MapIcon";
		protected $iconPath = null;
		
		function initialize()
		{
			$this->iconPath = WWW_ROOT.'geo_images'.DS;
			parent::initialize();
		}
		function getIconFileName($categoryId)
		{
			
		}
		
		function getIconsList()
		{
			$FolderObject = new Folder($this->iconPath);
			$files = $FolderObject->find();
			$files = array_diff($files,array("Thumbs.db","thumbs.db"));
			return $files;
		}
		
		function getCategoryIcons($noCache = false)
		{
			$cacheKey = "geomap_category_icons";
			
			GigaCache::set(array("path"=>CACHE,"duration"=>"+1 hour"));
			$categoryIcons = GigaCache::read($cacheKey);
			if(!is_array($categoryIcons) || $noCache == true)
			{
				$categoryIcons = $this->find("list",array('fields'=>array("category_id","icon")));
				GigaCache::write($cacheKey,$categoryIcons);
			}
			return $categoryIcons;
		}
	}
?>